﻿using CSRedis;
using DotNetCommon;
using furion.blog.Application.Contracts;
using furion.blog.Domain.Shared.Attribute;
using furion.blog.Domain.Shared.Dto.Menu;
using furion.blog.Domain.Shared.Enum;
using furion.blog.Utils;
using Furion.DynamicApiController;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json.Linq;

namespace furion.blog.Web.Entry.Api
{
    /// <summary>
    /// 系统相关接口
    /// </summary>
    [ApiDescriptionSettings(Groups = new string[] { "SystemApi" })]
    [Route("api/system")]
    public class SystemApiController : IDynamicApiController
    {

        public readonly ISystemService _systemService;
        public readonly ITagConfigService _tagConfigService;

        public SystemApiController(ISystemService systemService, ITagConfigService tagConfigService)
        {
            this._systemService = systemService;
            this._tagConfigService = tagConfigService;
        }

        /// <summary>
        /// 同步菜单
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        [ActionAttribute(Name = "菜单同步接口", Desc = "同步后台菜单数据")]
        [HttpPost, Route("menu/sync")]
        public async Task<IActionResult> sync([FromBody] List<MenuTreeNodeDto> data)
        {
            await this._systemService.SyncMenus(data);
            return new OkObjectResult(ResultUtil.Success());
        }
    }
}
